
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>NEMU ISA相关API说明文档 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-intopic-toc/style.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-callouts/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="styles.css">
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="i386-intro.html" />
    
    
    <link rel="prev" href="git.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="index.html">
            
                <a href="index.html">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="PA0.html">
            
                <a href="PA0.html">
            
                    
                    PA0 - 世界诞生的前夜: 开发环境配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="0.1.html">
            
                <a href="0.1.html">
            
                    
                    Installing GNU/Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="0.2.html">
            
                <a href="0.2.html">
            
                    
                    First Exploration with GNU/Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="0.3.html">
            
                <a href="0.3.html">
            
                    
                    Installing Tools
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="0.4.html">
            
                <a href="0.4.html">
            
                    
                    Configuring vim
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="0.5.html">
            
                <a href="0.5.html">
            
                    
                    More Exploration
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="0.6.html">
            
                <a href="0.6.html">
            
                    
                    Getting Source Code for PAs
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="PA1.html">
            
                <a href="PA1.html">
            
                    
                    PA1 - 开天辟地的篇章: 最简单的计算机
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="1.1.html">
            
                <a href="1.1.html">
            
                    
                    在开始愉快的PA之旅之前
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="1.2.html">
            
                <a href="1.2.html">
            
                    
                    开天辟地的篇章
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="1.3.html">
            
                <a href="1.3.html">
            
                    
                    RTFSC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="1.4.html">
            
                <a href="1.4.html">
            
                    
                    基础设施
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="1.5.html">
            
                <a href="1.5.html">
            
                    
                    表达式求值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="1.6.html">
            
                <a href="1.6.html">
            
                    
                    监视点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="1.7.html">
            
                <a href="1.7.html">
            
                    
                    如何阅读手册
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="PA2.html">
            
                <a href="PA2.html">
            
                    
                    PA2 - 简单复杂的机器: 冯诺依曼计算机系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="2.1.html">
            
                <a href="2.1.html">
            
                    
                    不停计算的机器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="2.2.html">
            
                <a href="2.2.html">
            
                    
                    RTFSC(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="2.3.html">
            
                <a href="2.3.html">
            
                    
                    程序, 运行时环境与AM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="2.4.html">
            
                <a href="2.4.html">
            
                    
                    基础设施(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="2.5.html">
            
                <a href="2.5.html">
            
                    
                    输入输出
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="PA3.html">
            
                <a href="PA3.html">
            
                    
                    PA3 - 穿越时空的旅程: 批处理系统
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="3.1.html">
            
                <a href="3.1.html">
            
                    
                    最简单的操作系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="3.2.html">
            
                <a href="3.2.html">
            
                    
                    穿越时空的旅程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="3.3.html">
            
                <a href="3.3.html">
            
                    
                    用户程序和系统调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="3.4.html">
            
                <a href="3.4.html">
            
                    
                    文件系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="3.5.html">
            
                <a href="3.5.html">
            
                    
                    精彩纷呈的应用程序
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="PA4.html">
            
                <a href="PA4.html">
            
                    
                    PA4 - 虚实交错的魔法: 分时多任务
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="4.1.html">
            
                <a href="4.1.html">
            
                    
                    多道程序
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="4.2.html">
            
                <a href="4.2.html">
            
                    
                    虚实交错的魔法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="4.3.html">
            
                <a href="4.3.html">
            
                    
                    超越容量的界限
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="4.4.html">
            
                <a href="4.4.html">
            
                    
                    来自外部的声音
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="4.5.html">
            
                <a href="4.5.html">
            
                    
                    编写不朽的传奇
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="blank.html">
            
                <a href="blank.html">
            
                    
                    杂项
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="FAQ.html">
            
                <a href="FAQ.html">
            
                    
                    常见问题(FAQ)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="why.html">
            
                <a href="why.html">
            
                    
                    为什么要学习计算机系统基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="linux.html">
            
                <a href="linux.html">
            
                    
                    Linux入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="man.html">
            
                <a href="man.html">
            
                    
                    man入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="git.html">
            
                <a href="git.html">
            
                    
                    git入门教程
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7.6" data-path="nemu-isa-api.html">
            
                <a href="nemu-isa-api.html">
            
                    
                    NEMU ISA相关API说明文档
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="i386-intro.html">
            
                <a href="i386-intro.html">
            
                    
                    i386手册指令集阅读指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="exec.html">
            
                <a href="exec.html">
            
                    
                    指令执行例子
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >NEMU ISA相关API说明文档</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="nemu-isa&#x76F8;&#x5173;&#x7684;api&#x8BF4;&#x660E;&#x6587;&#x6863;">NEMU ISA&#x76F8;&#x5173;&#x7684;API&#x8BF4;&#x660E;&#x6587;&#x6863;</h2>
<p>&#x4E3A;&#x4E86;&#x63D0;&#x9AD8;&#x6027;&#x80FD;, &#x8FD9;&#x4E9B;API&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5B8F;&#x5B9A;&#x4E49;&#x5B9E;&#x73B0;,
&#x4F46;&#x672C;&#x6587;&#x6863;&#x8FD8;&#x662F;&#x4EE5;C&#x53D8;&#x91CF;&#x6216;&#x51FD;&#x6570;&#x7684;&#x65B9;&#x5F0F;&#x5217;&#x51FA;, &#x4EE5;&#x7ED9;&#x51FA;&#x53D8;&#x91CF;&#x6216;&#x51FD;&#x6570;&#x7684;&#x7C7B;&#x578B;.</p>
<h3 id="&#x5168;&#x5C40;&#x7C7B;&#x578B;">&#x5168;&#x5C40;&#x7C7B;&#x578B;</h3>
<pre><code class="lang-c"><span class="hljs-keyword">word_t</span>;
</code></pre>
<p>&#x8868;&#x793A;&#x4E0E;ISA&#x5B57;&#x957F;&#x7B49;&#x957F;&#x7684;&#x65E0;&#x7B26;&#x53F7;&#x7C7B;&#x578B;, &#x5728;32&#x4F4D;&#x7684;ISA&#x4E2D;&#x4E3A;<code>uint32_t</code>, &#x5728;64&#x4F4D;&#x7684;ISA&#x4E2D;&#x4E3A;<code>uint64_t</code>.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-keyword">sword_t</span>;
</code></pre>
<p>&#x8868;&#x793A;&#x4E0E;ISA&#x5B57;&#x957F;&#x7B49;&#x957F;&#x7684;&#x6709;&#x7B26;&#x53F7;&#x7C7B;&#x578B;, &#x5728;32&#x4F4D;&#x7684;ISA&#x4E2D;&#x4E3A;<code>int32_t</code>, &#x5728;64&#x4F4D;&#x7684;ISA&#x4E2D;&#x4E3A;<code>int64_t</code>.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-keyword">char</span> *FMT_WORD;
</code></pre>
<p><code>word_t</code>&#x7C7B;&#x578B;&#x5BF9;&#x5E94;&#x7684;&#x5341;&#x516D;&#x8FDB;&#x5236;&#x683C;&#x5F0F;&#x5316;&#x8BF4;&#x660E;&#x7B26;, &#x5728;32&#x4F4D;&#x7684;ISA&#x4E2D;&#x4E3A;<code>&quot;0x%08x&quot;</code>, &#x5728;64&#x4F4D;&#x7684;ISA&#x4E2D;&#x4E3A;<code>&quot;0x%016lx&quot;</code>.</p>
<h3 id="monitor&#x76F8;&#x5173;">Monitor&#x76F8;&#x5173;</h3>
<pre><code class="lang-c"><span class="hljs-keyword">char</span> isa_logo[];
</code></pre>
<p>&#x7528;&#x4E8E;&#x5728;&#x672A;&#x5B9E;&#x73B0;&#x6307;&#x4EE4;&#x7684;&#x62A5;&#x9519;&#x4FE1;&#x606F;&#x4E2D;&#x63D0;&#x793A;&#x5F00;&#x53D1;&#x8005;&#x9605;&#x8BFB;&#x76F8;&#x5173;&#x7684;&#x624B;&#x518C;.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-keyword">word_t</span> RESET_VECTOR;
</code></pre>
<p>&#x8868;&#x793A;PC&#x7684;&#x521D;&#x59CB;&#x503C;.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">init_isa</span><span class="hljs-params">()</span></span>;
</code></pre>
<p>&#x5728;monitor&#x521D;&#x59CB;&#x5316;&#x65F6;&#x8C03;&#x7528;, &#x8FDB;&#x884C;&#x81F3;&#x5C11;&#x5982;&#x4E0B;ISA&#x76F8;&#x5173;&#x7684;&#x521D;&#x59CB;&#x5316;&#x5DE5;&#x4F5C;:</p>
<ul>
<li>&#x8BBE;&#x7F6E;&#x5FC5;&#x8981;&#x7684;&#x5BC4;&#x5B58;&#x5668;&#x521D;&#x503C;, &#x5982;<code>PC</code>&#x7B49;</li>
<li>&#x52A0;&#x8F7D;&#x5185;&#x7F6E;&#x5BA2;&#x6237;&#x7A0B;&#x5E8F;</li>
</ul>
<h3 id="&#x5BC4;&#x5B58;&#x5668;&#x76F8;&#x5173;">&#x5BC4;&#x5B58;&#x5668;&#x76F8;&#x5173;</h3>
<pre><code class="lang-c"><span class="hljs-keyword">struct</span> {
  <span class="hljs-comment">// ...</span>
  <span class="hljs-keyword">word_t</span> pc;
} CPU_state;
</code></pre>
<p>&#x5BC4;&#x5B58;&#x5668;&#x7ED3;&#x6784;&#x7684;&#x7C7B;&#x578B;&#x5B9A;&#x4E49;, &#x5176;&#x4E2D;&#x5FC5;&#x987B;&#x5305;&#x542B;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;<code>pc</code>, &#x7C7B;&#x578B;&#x4E3A;<code>word_t</code>&#x7684;&#x6210;&#x5458;.</p>
<hr>
<pre><code class="lang-c">CPU_state cpu;
</code></pre>
<p>&#x5BC4;&#x5B58;&#x5668;&#x7ED3;&#x6784;&#x7684;&#x5168;&#x5C40;&#x5B9A;&#x4E49;.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">isa_reg_display</span><span class="hljs-params">()</span></span>;
</code></pre>
<p>&#x7528;&#x4E8E;&#x6253;&#x5370;&#x5BC4;&#x5B58;&#x5668;&#x5F53;&#x524D;&#x7684;&#x503C;.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-keyword">word_t</span> isa_reg_str2val(<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *name, <span class="hljs-keyword">bool</span> *success);
</code></pre>
<p>&#x82E5;&#x5B58;&#x5728;&#x540D;&#x79F0;&#x4E3A;<code>name</code>&#x7684;&#x5BC4;&#x5B58;&#x5668;, &#x5219;&#x8FD4;&#x56DE;&#x5176;&#x5F53;&#x524D;&#x503C;, &#x5E76;&#x8BBE;&#x7F6E;<code>success</code>&#x4E3A;<code>true</code>;
&#x5426;&#x5219;&#x8BBE;&#x7F6E;<code>success</code>&#x4E3A;<code>false</code>.</p>
<h3 id="&#x6307;&#x4EE4;&#x6267;&#x884C;&#x76F8;&#x5173;">&#x6307;&#x4EE4;&#x6267;&#x884C;&#x76F8;&#x5173;</h3>
<pre><code class="lang-c"><span class="hljs-keyword">struct</span> {
  <span class="hljs-comment">// ...</span>
} ISADecodeInfo;
</code></pre>
<p>&#x7528;&#x4E8E;&#x5B58;&#x653E;ISA&#x76F8;&#x5173;&#x7684;&#x8BD1;&#x7801;&#x4FE1;&#x606F;, &#x4F1A;&#x5D4C;&#x5165;&#x5728;&#x8BD1;&#x7801;&#x4FE1;&#x606F;&#x7ED3;&#x6784;&#x4F53;<code>Decode</code>&#x7684;&#x5B9A;&#x4E49;&#x4E2D;.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-keyword">vaddr_t</span> isa_fetch_decode(Decode *s);
</code></pre>
<p>&#x53D6;&#x51FA;<code>s-&gt;pc</code>&#x6307;&#x5411;&#x7684;&#x6307;&#x4EE4;&#x5E76;&#x8BD1;&#x7801;, &#x540C;&#x65F6;&#x66F4;&#x65B0;<code>s-&gt;snpc</code>, &#x6700;&#x540E;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x7528;&#x4E8E;&#x6807;&#x8BC6;&#x6307;&#x4EE4;&#x6267;&#x884C;&#x8F85;&#x52A9;&#x51FD;&#x6570;&#x7684;ID.</p>
<h3 id="&#x865A;&#x62DF;&#x5185;&#x5B58;&#x76F8;&#x5173;">&#x865A;&#x62DF;&#x5185;&#x5B58;&#x76F8;&#x5173;</h3>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">isa_mmu_check</span><span class="hljs-params">(vaddr_t vaddr, <span class="hljs-keyword">int</span> len, <span class="hljs-keyword">int</span> type)</span></span>;
</code></pre>
<p>&#x68C0;&#x67E5;&#x5F53;&#x524D;&#x7CFB;&#x7EDF;&#x72B6;&#x6001;&#x4E0B;&#x5BF9;&#x5185;&#x5B58;&#x533A;&#x95F4;&#x4E3A;<code>[vaddr, vaddr + len)</code>, &#x7C7B;&#x578B;&#x4E3A;<code>type</code>&#x7684;&#x8BBF;&#x95EE;&#x662F;&#x5426;&#x9700;&#x8981;&#x7ECF;&#x8FC7;&#x5730;&#x5740;&#x8F6C;&#x6362;.
&#x5176;&#x4E2D;<code>type</code>&#x53EF;&#x80FD;&#x4E3A;:</p>
<ul>
<li><code>MEM_TYPE_IFETCH</code>: &#x53D6;&#x6307;&#x4EE4;</li>
<li><code>MEM_TYPE_READ</code>: &#x8BFB;&#x6570;&#x636E;</li>
<li><code>MEM_TYPE_WRITE</code>: &#x5199;&#x6570;&#x636E;</li>
</ul>
<p>&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;&#x53EF;&#x80FD;&#x4E3A;:</p>
<ul>
<li><code>MMU_DIRECT</code>: &#x8BE5;&#x5185;&#x5B58;&#x8BBF;&#x95EE;&#x53EF;&#x4EE5;&#x5728;&#x7269;&#x7406;&#x5185;&#x5B58;&#x4E0A;&#x76F4;&#x63A5;&#x8FDB;&#x884C;</li>
<li><code>MMU_TRANSLATE</code>: &#x8BE5;&#x5185;&#x5B58;&#x8BBF;&#x95EE;&#x9700;&#x8981;&#x7ECF;&#x8FC7;&#x5730;&#x5740;&#x8F6C;&#x6362;</li>
<li><code>MMU_FAIL</code>: &#x8BE5;&#x5185;&#x5B58;&#x8BBF;&#x95EE;&#x5931;&#x8D25;, &#x9700;&#x8981;&#x629B;&#x51FA;&#x5F02;&#x5E38;(&#x5982;RISC&#x67B6;&#x6784;&#x4E0D;&#x652F;&#x6301;&#x975E;&#x5BF9;&#x9F50;&#x7684;&#x5185;&#x5B58;&#x8BBF;&#x95EE;)</li>
</ul>
<hr>
<pre><code class="lang-c"><span class="hljs-keyword">paddr_t</span> isa_mmu_translate(<span class="hljs-keyword">vaddr_t</span> vaddr, <span class="hljs-keyword">int</span> len, <span class="hljs-keyword">int</span> type);
</code></pre>
<p>&#x5BF9;&#x5185;&#x5B58;&#x533A;&#x95F4;&#x4E3A;<code>[vaddr, vaddr + len)</code>, &#x7C7B;&#x578B;&#x4E3A;<code>type</code>&#x7684;&#x5185;&#x5B58;&#x8BBF;&#x95EE;&#x8FDB;&#x884C;&#x5730;&#x5740;&#x8F6C;&#x6362;.
&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;&#x53EF;&#x80FD;&#x4E3A;:</p>
<ul>
<li><code>pg_paddr</code> | <code>MEM_RET_OK</code>: &#x5730;&#x5740;&#x8F6C;&#x6362;&#x6210;&#x529F;, &#x5176;&#x4E2D;<code>pg_paddr</code>&#x4E3A;&#x7269;&#x7406;&#x9875;&#x9762;&#x7684;&#x5730;&#x5740;(&#x800C;&#x4E0D;&#x662F;<code>vaddr</code>&#x7FFB;&#x8BD1;&#x540E;&#x7684;&#x7269;&#x7406;&#x5730;&#x5740;)</li>
<li><code>MEM_RET_FAIL</code>: &#x5730;&#x5740;&#x8F6C;&#x6362;&#x5931;&#x8D25;, &#x539F;&#x56E0;&#x5305;&#x62EC;&#x6743;&#x9650;&#x68C0;&#x67E5;&#x5931;&#x8D25;&#x7B49;&#x4E0D;&#x53EF;&#x6062;&#x590D;&#x7684;&#x539F;&#x56E0;, &#x4E00;&#x822C;&#x9700;&#x8981;&#x629B;&#x51FA;&#x5F02;&#x5E38;</li>
<li><code>MEM_RET_CROSS_PAGE</code>: &#x5730;&#x5740;&#x8F6C;&#x6362;&#x5931;&#x8D25;, &#x539F;&#x56E0;&#x4E3A;&#x8BBF;&#x5B58;&#x8BF7;&#x6C42;&#x8DE8;&#x8D8A;&#x4E86;&#x9875;&#x9762;&#x7684;&#x8FB9;&#x754C;</li>
</ul>
<h3 id="&#x4E2D;&#x65AD;&#x5F02;&#x5E38;&#x76F8;&#x5173;">&#x4E2D;&#x65AD;&#x5F02;&#x5E38;&#x76F8;&#x5173;</h3>
<pre><code class="lang-c"><span class="hljs-keyword">vaddr_t</span> isa_raise_intr(<span class="hljs-keyword">word_t</span> NO, <span class="hljs-keyword">vaddr_t</span> epc);
</code></pre>
<p>&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x53F7;&#x7801;&#x4E3A;<code>NO</code>&#x7684;&#x5F02;&#x5E38;, &#x5176;&#x4E2D;<code>epc</code>&#x4E3A;&#x89E6;&#x53D1;&#x5F02;&#x5E38;&#x7684;&#x6307;&#x4EE4;PC, &#x8FD4;&#x56DE;&#x5F02;&#x5E38;&#x5904;&#x7406;&#x7684;&#x51FA;&#x53E3;&#x5730;&#x5740;.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-keyword">word_t</span> isa_query_intr();
</code></pre>
<p>&#x67E5;&#x8BE2;&#x5F53;&#x524D;&#x662F;&#x5426;&#x6709;&#x672A;&#x5904;&#x7406;&#x7684;&#x4E2D;&#x65AD;, &#x82E5;&#x6709;&#x5219;&#x8FD4;&#x56DE;&#x4E2D;&#x65AD;&#x53F7;&#x7801;, &#x5426;&#x5219;&#x8FD4;&#x56DE;<code>INTR_EMPTY</code>.</p>
<h3 id="difftest&#x76F8;&#x5173;">DiffTest&#x76F8;&#x5173;</h3>
<h4 id="nemu&#x4F5C;&#x4E3A;dut&#x65F6;&#x4F7F;&#x7528;">NEMU&#x4F5C;&#x4E3A;DUT&#x65F6;&#x4F7F;&#x7528;</h4>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">bool</span> <span class="hljs-title">isa_difftest_checkregs</span><span class="hljs-params">(CPU_state *ref_r, vaddr_t pc)</span></span>;
</code></pre>
<p>&#x68C0;&#x67E5;&#x5F53;&#x524D;&#x7684;&#x5BC4;&#x5B58;&#x5668;&#x72B6;&#x6001;&#x662F;&#x5426;&#x4E0E;<code>ref_r</code>&#x76F8;&#x540C;, &#x5176;&#x4E2D;<code>pc</code>&#x4E3A;<code>cpu.pc</code>&#x7684;&#x4E0A;&#x4E00;&#x6761;&#x52A8;&#x6001;&#x6307;&#x4EE4;&#x7684;PC, &#x5373;<code>cpu.pc</code>&#x7684;&#x65E7;&#x503C;.
&#x5982;&#x679C;&#x72B6;&#x6001;&#x76F8;&#x540C;, &#x5219;&#x8FD4;&#x56DE;<code>true</code>, &#x5426;&#x5219;&#x8FD4;&#x56DE;<code>false</code>.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">isa_difftest_attach</span><span class="hljs-params">()</span></span>;
</code></pre>
<p>&#x5C06;&#x5F53;&#x524D;&#x7684;&#x6240;&#x6709;&#x72B6;&#x6001;&#x540C;&#x6B65;&#x5230;REF, &#x5E76;&#x5728;&#x4E4B;&#x540E;&#x7684;&#x6267;&#x884C;&#x4E2D;&#x5F00;&#x542F;DiffTest.</p>
<h4 id="nemu&#x4F5C;&#x4E3A;ref&#x65F6;&#x4F7F;&#x7528;">NEMU&#x4F5C;&#x4E3A;REF&#x65F6;&#x4F7F;&#x7528;</h4>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">isa_difftest_regcpy</span><span class="hljs-params">(<span class="hljs-keyword">void</span> *dut, <span class="hljs-keyword">bool</span> direction)</span></span>;
</code></pre>
<p><code>direction</code>&#x4E3A;<code>DIFFTEST_TO_DUT</code>&#x65F6;, &#x83B7;&#x53D6;REF&#x7684;&#x5BC4;&#x5B58;&#x5668;&#x72B6;&#x6001;&#x5230;<code>dut</code>;
<code>direction</code>&#x4E3A;<code>DIFFTEST_TO_REF</code>&#x65F6;, &#x8BBE;&#x7F6E;REF&#x7684;&#x5BC4;&#x5B58;&#x5668;&#x72B6;&#x6001;&#x4E3A;<code>dut</code>.</p>
<hr>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">isa_difftest_raise_intr</span><span class="hljs-params">(word_t NO)</span></span>;
</code></pre>
<p>&#x89E6;&#x53D1;&#x4E00;&#x4E2A;&#x7F16;&#x53F7;&#x4E3A;<code>NO</code>&#x7684;&#x5F02;&#x5E38;.</p>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> By <a href="https://sashimi-yzh.github.io/" target="_blank">Zihao Yu</a>, &#x91C7;&#x7528;<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank">&#x77E5;&#x8BC6;&#x5171;&#x4EAB; &#x7F72;&#x540D;-&#x975E;&#x5546;&#x4E1A;&#x6027;&#x4F7F;&#x7528;-&#x76F8;&#x540C;&#x65B9;&#x5F0F;&#x5171;&#x4EAB; 3.0 &#x4E2D;&#x56FD;&#x5927;&#x9646; &#x8BB8;&#x53EF;&#x534F;&#x8BAE;</a>&#x53D1;&#x5E03; </span> &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0; <span class="page-footer-ex-footer-update"> &#x6B64;&#x9875;&#x9762;&#x4FEE;&#x8BA2;&#x4E8E;:  2022-09-03 14:01:19 </span> </footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="git.html" class="navigation navigation-prev " aria-label="Previous page: git入门教程">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="i386-intro.html" class="navigation navigation-next " aria-label="Next page: i386手册指令集阅读指南">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"NEMU ISA相关API说明文档","level":"1.7.6","depth":2,"next":{"title":"i386手册指令集阅读指南","level":"1.7.7","depth":2,"path":"i386-intro.md","ref":"i386-intro.md","articles":[]},"previous":{"title":"git入门教程","level":"1.7.5","depth":2,"path":"git.md","ref":"git.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"3.x.x","theme":"default","variables":{},"plugins":["theme-comscore","intopic-toc","localized-footer","page-footer-ex","callouts"],"pluginsConfig":{"callouts":{"option":{"alert":"info","picto":"fa-edit"},"flag":{"alert":"success","picto":"fa-flag"},"question":{"alert":"info","picto":"fa-question-circle"},"info":{"alert":"info","picto":"fa-info-circle"},"todo":{"alert":"warning","picto":"fa-edit"},"caution":{"alert":"danger","picto":"fa-bullhorn"},"danger":{"alert":"danger","picto":"fa-exclamation"},"showTypeInHeader":false},"intopic-toc":{"isCollapsed":false,"isScrollspyActive":true,"label":"导航","maxDepth":6,"mode":"nested","selector":".markdown-section h2, .markdown-section h3, .markdown-section h4","visible":true},"page-footer-ex":{"copyright":"By [Zihao Yu](https://sashimi-yzh.github.io/), 采用[知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议](http://creativecommons.org/licenses/by-nc-sa/3.0/cn/)发布","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"此页面修订于: "},"search":{},"localized-footer":{"filename":"FOOTER.md","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles.css","pdf":"styles.css"}},"file":{"path":"nemu-isa-api.md","mtime":"2022-09-03T06:01:19.491Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-09-03T06:01:34.685Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-intopic-toc/anchor.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-intopic-toc/gumshoe.polyfills.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-intopic-toc/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

